/*  Explores azimuths of installed systems in California Solar Initiative (CSI) database.

NOTES:

*/

clear all

*change "mainpath" below to your folder location
global mainpath `"Z:/user/rih4/Solar Siting"'

*shouldn't need to change these paths if your folders are named the same
cd `"${mainpath}/JAERE Code Repository"'
global data_path `"Data JAERE"'
global data_intermediate `"${data_path}/intermediate_output"'
global data_final `"${data_path}/final_output"'

import delimited `"${data_path}/CSI_WorkingDataSet_10-23-2019.csv"', numericcols(111 112) 
egen binned_azimuth = cut( csiprojectazimuth ), at(0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,255,260,265,270,275,280,285,290,295,300,305,310,315,320,325,330,335,340,345,350,355,360)
tab binned_azimuth
sum csiprojecttilt

sum csiprojectazimuth
sum csiprojectazimuth if csiprojectazimuth>=150 & csiprojectazimuth<=210
sum csiprojectazimuth if csiprojectazimuth>=135 & csiprojectazimuth<=225
sum csiprojectazimuth if csiprojectazimuth>=165 & csiprojectazimuth<=195


histogram csiprojectazimuth if csiprojectazimuth<=360, ///
plotregion(color(white)) graphregion(color(white))
graph export `"${data_final}/csi_azimuth.pdf"', replace
